<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>

    <!-- 18.2.0 最新的 -->
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/prop-types.js"></script>
    <script src="./js/babel.min.js"></script>

    <script type="text/babel">
      // console.log(React, ReactDOM, PropTypes)

      class App extends React.Component {
        handleClick() {
          this.props.hello();
        }

        render() {
          return (
            <div>
              <h1>App</h1>
              <button onClick={this.handleClick.bind(this)}>点我</button>
            </div>
          );
        }
      }

      // prop的校验
      App.propTypes = {
        hello: PropTypes.func,
      };

      // prop的默认值
      App.defaultProps = {
        hello: () => {
          console.log("default Hello");
        },
      };

      ReactDOM.createRoot(document.querySelector("#root")).render(<App />);
    </script>
  </body>
</html>
